/*
 * @Author: LVGRAPE
 * @LastEditors: LVGRAPE
 */
#ifndef __DRV_SERIAL_H__
#define __DRV_SERIAL_H__

#include <rtthread.h>
#include <rthw.h>
#include "at32f413.h"
#include "board.h"
#include "drv_pin.h"
#include "ringbuffer.h"

#define SERIAL_RX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_SIZE 64

#define UART_TX DMA_DIR_PERIPHERALDST
/*periph to memory*/
#define UART_RX DMA_DIR_PERIPHERALSRC

#ifdef __cplusplus
extern "C"
{
#endif

    int16_t usart1_get_rx_data_len(void);
    int uart1_read(uint8_t *buf, rt_size_t size);
    int uart1_write(uint8_t *buf, rt_size_t size);
    int uart4_write(uint8_t *buf, rt_size_t size);
    int uart4_read(uint8_t *buf, rt_size_t size);
    int16_t uart4_get_rx_data_len(void);
    char uart4_getc(void);
    uint8_t uart4_getByte(void);
    void rt_hw_uart4_init(void);
    void uart4_printf(const char *fmt, ...);
#ifdef __cplusplus
}
#endif

#endif /* __DRV_SERIAL_H__ */
